]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Support resource:/// URL's in GNOME_SHELL_JS envvar
authorOwen W. Taylor <otaylor@fishsoup.net>
Mon, 19 May 2014 23:14:21 +0000 (19:14 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Tue, 20 May 2014 00:47:05 +0000 (20:47 -0400)
It can be useful to augment the shell's search path by doing

 GNOME_SHELL_JS=resource:///org/gnome/shell:<mypath>

But this doesn't work because resource: is split off. Special
case path elements that are just 'resource' and recombine
them with the next element.

https://bugzilla.gnome.org/show_bug.cgi?id=730409

src/shell-global.c

index 78d149faed9b6ec266521feb3fbe44628253f91f..f527c0f39282017d1c5cc03b25c9c84700129c3b 100644 (file)
@@ -286,7 +286,33 @@ shell_global_init (ShellGlobal *global)
 
   if (shell_js)
     {
+      int i, j;
       search_path = g_strsplit (shell_js, ":", -1);
+
+      /* The naive g_strsplit above will split 'resource:///foo/bar' into 'resource',
+       * '///foo/bar'. Combine these back together by looking for a literal 'resource'
+       * in the array. */
+      for (i = 0, j = 0; search_path[i];)
+        {
+          char *out;
+
+          if (strcmp (search_path[i], "resource") == 0 && search_path[i + 1] != NULL)
+            {
+              out = g_strconcat (search_path[i], ":", search_path[i + 1], NULL);
+              g_free (search_path[i]);
+              g_free (search_path[i + 1]);
+              i += 2;
+            }
+          else
+            {
+              out = search_path[i];
+              i += 1;
+            }
+
+          search_path[j++] = out;
+        }
+
+      search_path[j] = NULL; /* NULL-terminate the now possibly shorter array */
     }
   else
     {